import { reactive, ref } from "vue";
import type { SelectProps } from "ant-design-vue";
export default function InitHook(state: Base.GeneraDataType) {
  const { dataDict } = state;

  //表单数据
  const formState = reactive<CustomerServiceWaybill.CreateWorkOrderForm>({
    questionScope: "", //	运单号
    questionType: "", //	转单号
    questionDesc: "", //问题描述
    shipmentLimit: 0 //业务状态限制
  });

  //等待状态
  const loading = ref<boolean>(false);

  const options = ref<SelectProps["options"]>([]);

  const changeOptions = (e: string) => {
    formState.questionType = "";
    if (e === "PRE_PORT_SCOPE") {
      options.value = dataDict.value["PRE_PORT_SCOPE"];
    } else {
      options.value = dataDict.value["AFTER_PORT_SCOPE"];
    }
  };

  //表单ref
  const formRef = ref(null);
  return {
    formState,
    loading,
    formRef,
    options,
    changeOptions
  };
}
